<!doctype html>
<html>
  <head>
    <title>polymer-file</title>
    <script src="../../../polymer/polymer.js"></script>
    <script src="../../../polymer/tools/test/htmltest.js"></script>
    <script src="../../node_modules/chai/chai.js"></script>
    <link rel="import" href="../../polymer-file/polymer-file.html">
  </head>
  <body>

    <polymer-file auto readas="text"></polymer-file>
    
    <script>
      var assert = chai.assert;
      document.addEventListener('WebComponentsReady', function() {
        var DATA = 'abc123';

        var pfile = document.querySelector('polymer-file');

        assert.isNull(pfile.blob);
        assert.isTrue(pfile.auto);
        assert.equal(pfile.readas, 'text');
        assert.isNull(pfile.result, ".auto doesn't start a read");

        pfile.blob = new Blob([DATA], {type: 'text/plain'});

        pfile.addEventListener('polymer-result', function(e) {
          assert.isDefined(e.detail.result);
          assert.isString(e.detail.result, 'Result is a text string');
          assert.equal(e.detail.result, DATA, 'Result correct data');
          assert.equal(pfile.result, DATA, '.result was set correctly');

          done();
        });
        //pfile.read();
      });
    </script>
  </body>
</html>
